
cmake_minimum_required(VERSION 3.5.1)

project(cpu-rank-search LANGUAGES CXX VERSION 1.0)

include(cmake/SparkWithGit.cmake)
spark_initialize_modules()

spark_add_links_qt(
    Concurrent
    WebEngine
    WebEngineWidgets
)

# 资源文件路径
set(QRC_SOURCES "src/resources.qrc")
spark_add_executable_path(${PROJECT_NAME} src
    ${QRC_SOURCES}

    src/NetworkRequest
    src/QtPrivateDeclar
    src/QuickTemplateObject

    src/ui
    src/ui/widgets

#    src/ui/qml/CpuInfoBrowser.qmlc
)
target_link_qt5(${PROJECT_NAME})
target_link_qt_concurrent(${PROJECT_NAME})
target_link_qt_webengine(${PROJECT_NAME})
target_link_qt_webenginewidgets(${PROJECT_NAME})

spark_framework_include_with_git(${PROJECT_NAME}
    https://gitee.com/spark-framework-libs/spark-framework-features
    FEATURES version screenutil qrcutil)

spark_framework_include_with_git(${PROJECT_NAME}
    https://gitee.com/spark-framework-libs/network-access-libs
    FEATURES httpmanager)

# 默认不构建(不参与 App 构建)
option(ENABLE_BUILD_EXAMPLES "Enable Build Examples." OFF)
if(ENABLE_BUILD_EXAMPLES)
    # cpurank-widgets
    spark_add_library_path(cpurank-widgets
        src/ui/widgets
        ${QRC_SOURCES}
    )
    target_link_qt(cpurank-widgets)
    target_link_qt_concurrent(cpurank-widgets)
    target_link_qt_webengine(cpurank-widgets)
    target_link_qt_webenginewidgets(cpurank-widgets)

    spark_framework_include_with_git(cpurank-widgets
        https://gitee.com/spark-framework-libs/spark-framework-features
        FEATURES qrcutil)

    spark_framework_include_with_git(cpurank-widgets
        https://gitee.com/spark-framework-libs/network-access-libs
        FEATURES httpmanager)

    include(examples/dev.cmake)
endif(ENABLE_BUILD_EXAMPLES)

# 部分测试
add_subdirectory(tests)

# spark_include(cmake/SparkDesktopMacros.cmake)
# 内容默认应用名称: Name= 应与项目名称相同
spark_desktop_macros(
    # 应用名称: Name=
    "cpu-rank-search"
    # 应用名称: Name[zh_CN]=
    "CPU 排名搜索工具"
    # 应用说明: Comment=
    "搜索你的CPU排名"
    # 应用类型: Type=
    "Application"
    # 执行程序: Exec=
    "cpu-rank-search"
    # 图标路径: Icon=
    "cpu"
    # 应用分类: Categories=
    "Development;"
    # MIME类型: MimeType=
)
install(FILES ${SPARK_DESKTOP_FILE} DESTINATION share/applications)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)

# other/ztbox
spark_add_shared_library_path(cpu-rank-plugin
    src/ui/widgets # 插件所 new 的 widget 源文件。
    ${QRC_SOURCES}

    other/ztbox
)
target_link_qt(cpu-rank-plugin)
target_link_qt_concurrent(cpu-rank-plugin)
target_link_qt_webengine(cpu-rank-plugin)
target_link_qt_webenginewidgets(cpu-rank-plugin)
spark_framework_include_with_git(cpu-rank-plugin
    https://gitee.com/zinface/z-tools-toolbox
    FEATURES plugin)
spark_framework_include_with_git(cpu-rank-plugin
    https://gitee.com/spark-framework-libs/network-access-libs
    FEATURES httpmanager)
spark_framework_include_with_git(cpu-rank-plugin
    https://gitee.com/spark-framework-libs/spark-framework-features
    FEATURES qrcutil)

# 注释行(使用方式)
spark_include(SparkDebPackageConfig.cmake)
add_package_descript(cmake/spark-deb-package.descript)
